package cn.edu.neusoft.wuguangsheng.market.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.market.R;
import cn.edu.neusoft.wuguangsheng.market.adapter.FoodByShopAdapter;
import cn.edu.neusoft.wuguangsheng.market.bean.FoodByShopBean;
import cn.edu.neusoft.wuguangsheng.market.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.market.model.FoodByShopModel;

public class FoodByShopActivity extends BaseActivity {
    RecyclerView recycler;
    private List<FoodByShopBean> items;
    String mrid;
     TextView tv_mr;
    String mrname;
    String pic;
    ImageView imgnm,mrfh;
    String nmpic;
    TextView address,phone;
    String mriphone,mraddress;
   // String uid=getid();
    @Override
    void initView() {
        setLayout_file(R.layout.activity_food_by_shop);
        tv_mr=(TextView)findViewById(R.id.tv_mr);
        imgnm=(ImageView)findViewById(R.id.imgnm);
        address=(TextView)findViewById(R.id.mrdz);
        phone=(TextView)findViewById(R.id.mrdh);
        mrfh=(ImageView)findViewById(R.id.mrfh);
        recycler=(RecyclerView)findViewById(R.id.recyfoodbyshop);
        mrid=getIntent().getStringExtra("SHOPID");
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(FoodByShopActivity.this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recycler.setLayoutManager(linearLayoutManager);
        mrname=getIntent().getStringExtra("mrname");
        nmpic=getIntent().getStringExtra("Pic");
        mriphone=getIntent().getStringExtra("phone");
        mraddress=getIntent().getStringExtra("address");
        tv_mr.setText(mrname);
        address.setText("地址:"+mraddress);
        phone.setText("电话:"+mriphone);
    }

    @Override
    void initEvent() {
mrfh.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        finish();
    }
});
    }

    @Override
    void initDate() {
        FoodByShopModel foodByShopModel=new FoodByShopModel();
        foodByShopModel.getFoodByShopMessage(mrid,foodByShopBeanListListener);
    }
ListListener<FoodByShopBean> foodByShopBeanListListener=new ListListener<FoodByShopBean>() {
    @Override
    public void onResponse(List<FoodByShopBean> list) {
        items=list;
        FoodByShopAdapter adapter=new FoodByShopAdapter(FoodByShopActivity.this,items,R.layout.newfoodbyshop);
        recycler.setAdapter(adapter);
        recycler.setItemAnimator(new DefaultItemAnimator());
        Picasso.with(FoodByShopActivity.this).load(nmpic).into(imgnm);


    }

    @Override
    public void onFail(String msg) {
    }

};

}
